/*
 * Copyright (c) GoKeep by gokeep.org. 2022-2023. All rights reserved
 */
package org.gokeep.application.rest;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.gokeep.common.dto.UserDetailDto;
import org.gokeep.common.dto.UserRegisterDto;
import org.gokeep.communication.service.UserService;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/user")
public class UserApi {
    @Resource
    private UserService userService;


    /**
     * 用户注册
     */
    @PostMapping("/register")
    public void register(@RequestBody UserRegisterDto userRegister) {
        log.info("Request to UserApi.register: {}", userRegister);
        userService.registerUser(userRegister);
    }


    @GetMapping("/{userId}")
    public UserDetailDto detail(@PathVariable("userId") String userId) {
          log.info("Request to UserApi.detail: {}", userId);
          return userService.detail(userId);
    }
}
